092b74d3ae1b1f1b73cd048476ab2f6bc863b9da,src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java,GregtechMetaTileEntityTreeFarm,plantSaplings,#IGregTechTileEntity#,436
Before Change
for (int j = -7; j <= 7; j++) {
int h = 1;
if (TreefarmManager.isAirBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))){
for (ItemStack n : r){
if (n != null){
if (OrePrefixes.sapling.contains(n) || n.getDisplayName().toLowerCase().contains("sapling")){
Utils.LOG_INFO(""+n.getDisplayName());
int posX, posY, posZ;
posX = aBaseMetaTileEntity.getXCoord()+xDir+i;
After Change
int h = 1;
if ((i != -7 && i != 7) && (j != -7 && j != 7)) {
if (TreefarmManager.isAirBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))){
//Utils.LOG_INFO("Found air");
if (r.size() > 0){
Utils.LOG_INFO("r was not null. "+r.size());
for (ItemStack n : r){
Utils.LOG_INFO("found "+n.getDisplayName());
if (OrePrefixes.sapling.contains(n) || n.getDisplayName().toLowerCase().contains("sapling")){
//Utils.LOG_INFO(""+n.getDisplayName());
int posX, posY, posZ;
posX = aBaseMetaTileEntity.getXCoord()+xDir+i;
posY = aBaseMetaTileEntity.getYCoord()+h;
posZ = aBaseMetaTileEntity.getZCoord()+zDir+j;
//Works for everything but forestry saplings - TODO
Block saplingToPlace;
if (n.getClass().getName().toLowerCase().contains("forestry")){
Utils.LOG_INFO("It's a forestry sapling, trying magic.");
saplingToPlace = Block.getBlockFromItem(ItemUtils.getItem("Forestry:saplingGE"));
}
else {
saplingToPlace = Block.getBlockFromItem(n.getItem());
}
//If sapling block is not null
if (saplingToPlace != null){
Utils.LOG_INFO("Placing Sapling Block.");
//Plant Sapling
world.setBlock(posX, posY, posZ, saplingToPlace);
world.setBlockMetadataWithNotify(posX, posY, posZ, n.getItemDamage(), 4);
//Deplete Input stack
depleteInput(n);
r = getStoredInputs();
break;
}
Utils.LOG_INFO(n.getDisplayName()+" did not have a valid block.");
}
else {
Utils.LOG_INFO("item was not a sapling");
}
}
}
else{
Utils.LOG_INFO("Input stack empty or null");
}
}
else {
Utils.LOG_INFO("No space for sapling, no air.");
}
}